package com.zimmor.mq.rocket_train1.base;

import com.zimmor.mq.RocketMQProperties;
import org.apache.rocketmq.client.exception.MQBrokerException;
import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.remoting.exception.RemotingException;
import sun.text.resources.cldr.bn.FormatData_bn_IN;

/**
 * @Author:zimmor
 * @Date: 2023/2/16 14:36
 * @Description 发送同步消息
 * @version: 1.0.0
 */

public class SyncProducer {
    public static void main(String[] args) throws MQClientException, RemotingException, InterruptedException, MQBrokerException {
        DefaultMQProducer producer = new DefaultMQProducer("producer-group1");
        producer.setNamesrvAddr(RocketMQProperties.NAME_SRV_ADDR);
        producer.start();
        for (int i = 0; i < 10; i++) {
            Message message = new Message("base1", "tag1", ("syncMessage" + i).getBytes());
            SendResult sendResult = producer.send(message);
            System.out.println("msg:" + sendResult.toString());
        }
        producer.shutdown();
    }
}
